package datastructure.day03;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * @author: Gan
 * @date 2021/4/30 0030 21:03
 * @description: 看一下JDK中ArrayList的Iterator方法,
 * 在我们自己曾经写过的MyArrayList的基础上, 也仿照实现一个iterator方法
 **/
public class DemoMyListBasedArray {
    public static void main(String[] args) {
        //new ArrayList<>()
        MyListBasedArray myListBasedArray = new MyListBasedArray();
        System.out.println(myListBasedArray.isEmpty());
        myListBasedArray.addValue(0, "play");
        myListBasedArray.addValue(1, "swim");
        myListBasedArray.addValue(2, "study");

        Iterator it = myListBasedArray.iterator();
        while (it.hasNext()) {
            Object next = it.next();
            it.remove();
            System.out.println(next);
        }
        it.remove();
    }
}
